<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>用户登录</title>
    <!-- 以上代码告诉IE浏览器,IE8/9及以后的版本都会以最高版本IE来渲染页面 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="alternate icon" type="image/png" href="amazeui/i/favicon.png">
    <link rel="stylesheet" href="amazeui/css/amazeui.css"/>
    <link rel="stylesheet" href="css/default.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="js/bootstrap.min.js"></script>
    <script src="js/md5.js"></script>
    <script src="js/jquery-3.2.1.js"></script>
    <script>
        function change(){
            document.getElementById("codeImg").src = "${pageContext.request.contextPath}/randomCode?time=" + new Date().getTime();
        }

        $(function (){
            $("#refresh").click(function (){
                $("#codeImg").src = "${pageContext.request.contextPath}/randomCode?time=" + new Date().getTime();
            });
        });
        $(function (){
            $("#sub").click(function (){
                $("#pwd").val(hex_md5($("#password").val()));
                return true;
            });
        });
        $(function (){
            $("#loginForm").submit(function (){
                let username = $("#username").val();
                let pwd = $("#password").val();
                if (username !== "" && pwd !== ""){
                    return true;
                }else {
                    return false;
                }
            });
        });
        $(function (){
            $(".close").click(function (){
                $(".alert").remove();
            });
        })
    </script>
</head>
<body>
<div class="header">
    <div class="am-g">
        <h1>管理员登录</h1>
    </div>
    <hr />
</div>
<div class="am-g">
    <div class="am-u-lg-6 am-u-md-8 am-u-sm-centered">
        <form id="loginForm" method="post" class="am-form" action="${pageContext.request.contextPath}/user/login">
            <div class="login-form-div">
                <label for="user">用户名：</label>
                <input type="text" name="username"  id="user" value="" placeholder="请输入登录名"  />
            </div>
            <div class="login-form-div">
                <label for="password">密码：</label>
                <input type="password"  id="password" value="" placeholder="请输入登录密码"  />
                <input type="hidden" name="password" id="pwd">
            </div>
            <div class="login-form-div">
                <label for="checkCode">验证码：</label>
                <input style="width: 250px;" type="text" name="checkCode" id="checkCode" placeholder="请输入下方验证码" />
            </div>
            <div class="login-form-div">
                <img style="width: 100px; height: 50px;" id="codeImg" src="${pageContext.request.contextPath}/randomCode" onclick="change()" title="看不清点击刷新"/>
                <span> <a href="" id="refresh">点击刷新</a></span>
            </div>
            <div class="login-form-div alert alert-warning alert-dismissible" style="width: 250px;height: 45px;" role="alert">
                <button type="button" class="close">
                    <span>&times;</span>
                </button>
                <strong id="msg">${msg}</strong>
            </div>
            <div class="login-form-div">
                <!--        <label for="remember-me">-->
                <!--          <input id="remember-me" type="checkbox">-->
                <!--          记住密码-->
                <!--        </label>-->
                <a href="findPwd.jsp" class="am-btn am-btn-default am-btn-sm am-fr">忘记密码 ^_^?</a>
                <%--<input type="button" name="" value="忘记密码 ^_^? " class="am-btn am-btn-default am-btn-sm am-fr">--%>
            </div>
            <div class="am-cf login-form-div">
                <input type="submit" name="" value="登 录" class="am-btn am-btn-primary am-btn-lg  am-btn-block am-fl" id="sub">
                <a href="regist.jsp" class="am-btn am-btn-danger am-btn-lg  am-btn-block am-fl">去注册</a>
            </div>
        </form>
        <hr>
        <p class="am-text-center">&copy; 2021 Designed by hz,chn,tx,zyj   <a href="mailTo:liyan@itany.com">liyan@itany.com</a> </p>
    </div>
</div>
</body>
</html>
